package com.lz.library.base

import androidx.databinding.ViewDataBinding

abstract class LazyFragment<VM : BaseViewModel<*>, B : ViewDataBinding> : BaseFragment<VM, B>() {

    private var isLoaded: Boolean = false

    override fun onResume() {
        super.onResume()
        if (!isLoaded && !isHidden) {
            lazyLoad()
            isLoaded = true
        }
    }

    override fun onDestroyView() {
        isLoaded = false
        super.onDestroyView()
    }

    protected abstract fun lazyLoad()
}